/*=====================================================================
  This file is part of a Microsoft SQL Server Shared Source Application.
  Copyright (C) Microsoft Corporation.  All rights reserved.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
======================================================= */

using System;
using System.Xml;
using System.Xml.Serialization;

namespace Microsoft.SqlServer.BISystems.Tool
{
    /// <summary>
    /// This class defines information included in Template. 
    /// </summary>
    [Serializable]
    [XmlRoot]
    public class ASQueryTemplate
    {
        private string m_server;

        [XmlElement(ElementName = "Server")]
        public string Server
        {
            get
            {
                return m_server;
            }
            set
            {
                try
                {
                    m_server = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"Server\" with value: " + value, e);
                }
            }
        }

        private string m_db;

        [XmlElement(ElementName = "Database")]
        public string Database
        {
            get
            {
                return m_db;
            }
            set
            {
                try
                {
                    m_db = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"Database\" with value: " + value, e);
                }
            }
        }

        private string m_cube;

        [XmlElement(ElementName = "Cube")]
        public string Cube
        {
            get
            {
                return m_cube;
            }
            set
            {
                try
                {
                    m_cube = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"Cube\" with value: " + value, e);
                }
            }
        }

        private string[] m_templateQueries;

        [XmlArray(ElementName = "Queries")]
        [XmlArrayItem(ElementName = "Query")]
        public string[] TemplateQueries
        {
            get
            {
                return m_templateQueries;
            }
            set
            {
                try
                {
                    m_templateQueries = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"Queries\" or \"Query\" with value: " + value, e);
                }
            }
        }

        private Tokens m_tokens;

        [XmlElement(ElementName = "Tokens")]
        public Tokens Tokens
        {
            get
            {
                return m_tokens;
            }
            set
            {
                try
                {
                    m_tokens = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"Tokens\"", e);
                }
            }
        }

        private Nullable<int> m_randSeed;

        [XmlElement(DataType = "string", ElementName = "RandomSeed", IsNullable = true)]
        public string RandomSeed_Tag
        {
            get
            {
                string seed;

                if (m_randSeed.HasValue)
                    seed = m_randSeed.Value.ToString();
                else
                    seed = null;

                return seed;
            }
            set
            {
                try
                {
                    if (value == null || value == "")
                        m_randSeed = null;
                    else
                        m_randSeed = Int32.Parse(value);
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"RandomSeed\" with value: " + value, e);
                }
            }
        }

        [XmlIgnore]
        public Nullable<int> RandomSeed
        {
            get
            {
                return m_randSeed;
            }
            set
            {
                m_randSeed = value;
            }
        }

        private ClientFile m_cfInfo;

        [XmlElement(ElementName = "ClientFile")]
        public ClientFile ClientFileInfo
        {
            get
            {
                return m_cfInfo;
            }
            set
            {
                try
                {
                    m_cfInfo = value;
                }
                catch (Exception e)
                {
                    throw new Exception("Error when deserializing XML tag \"ClientFile\"", e);
                }
            }
        }

        /// <summary>
        /// Default constructor. 
        /// </summary>
        public ASQueryTemplate()
        {
        }
    }
}
